import {Pane, Splitpanes} from "splitpanes";
import 'splitpanes/dist/splitpanes.css'

export const modelMixins = {
    components: {Splitpanes, Pane},
    emits: ['initOk'],
    props: {
        paneSize: {
            minSize: 20, maxSize: 80
        }
    },
    data() {
        return {
            formConfig: undefined,
        }
    }, methods: {
        initOk(e) {
            let {theme, table, customerForm} = e;
            if (this.searchRow == '1' && theme == 't1') {
                this.formConfig = table.formConfig;//给原有的自定义搜索
                customerForm();//执行自定义表单，这个方法会隐藏table的表单，隐藏搜索按钮
                this.customerForm = customerForm
            }
            this.$emit('initOk', e)
        }, setDataSource(data) {
            this.$nextTick(() => {
                let keys = Object.keys(data).filter(o => o.toString().length == 2 && o.toString().indexOf("t") == 0);
                for (let key of keys) {
                    if (this.$refs[key]) {
                        this.$refs[key].setDataSource(data[key])
                    } else {
                        if (this.$refs.splitpanesModel.$refs[key]) {
                            this.$refs.splitpanesModel.$refs[key].setDataSource(data[key])
                        } else {
                            this.$refs.splitpanesModel1.$refs[key].setDataSource(data[key])
                        }
                    }
                }
            })
        }
    }
}
